function searcher(){
	document.indexForm.submit();
}

function trim(val)
 {
	return val.replace(/(\s*$)/g, "");  
}

function changeAll(){
	var listsize = document.getElementById('listsize').value;
	var pkid_string = '';
	for(var i=0;i<listsize;i++){
		if(document.getElementById('checkone'+i).checked){
			
			if(trim(document.getElementById('cust_class_name_'+i).value) == ''){
				alert("级别名称不能为空！");
				return false;
			}
			pkid_string += document.getElementById('checkone'+i).value +','+ document.getElementById('cust_class_name_'+i).value+','+document.getElementById('class_type_'+i).value+'|';
		}
	}
	if(pkid_string == ''){
		alert('请至少选择一条!');
		return false;
	}
	document.getElementById('pkid').value = pkid_string;
	document.getElementById('bpm_id').value = '1301';
	document.indexForm.action='/doTradeReg.do';
	if(window.confirm('确认修改吗?')){
		document.indexForm.submit();
	}
}

function submitForm(){
	var cust_class = trim(document.getElementById('cust_class').value);
	var cust_class_name = trim(document.getElementById('cust_class_name').value);
	var class_type = trim(document.getElementById('class_type').value);
	
	if(cust_class == ''){
		alert("请输入级别代码");
		document.getElementById('cust_class').focus;
		return false;
	}
	if(cust_class>9){
		alert("级别代码只能是0-9的单个数字！");
		document.getElementById('cust_class').value='';
		document.getElementById('cust_class').focus;
		return false;
	}
	if(cust_class_name == ''){
		alert("请输入级别名称");
		document.getElementById('cust_class').focus;
		return false;
	}
	if(class_type == ''){
		alert("请选择级别类型");
		document.getElementById('cust_class').focus;
		return false;
	}
	document.addForm.submit();	
}

function checkcustclass(){
	var cust_class = document.getElementById('cust_class').value;
	var bool = true;
	jQuery.ajax({
		type: "POST",
		url: "checkCustClass.jsp",
		data:"cust_class=" + cust_class,
		success: function(data){
			 if(data!=null && trim(data)!=""){
				if( data == 1 ){
					alert('该级别代码已存在，请重新设置！');
					document.getElementById('cust_class').value = '';
					document.getElementById('cust_class').focus();
					bool = false;
				}
			 }
		}
	});
	return bool;
}